package kr.co.doriclassic.rps;

import java.util.Scanner;

public class Game {
	int usr;
	int cpu;

	public Game() {
		usr = -1;
		cpu = -1;
	}
	
	public void setValue(int v){
		usr=v;		
	}
	
	public String getValue(int v){
		String r = null;
		switch (v) {
			case 0:
				r = "가위";
				break;
			case 1:
				r = "바위";
				break;
			case 2:
				r = "보";
				break;
		}
		return r;
	}
	
	public void setCpu(){
		cpu = (int)(Math.random()*3);
	}
	
	
	//이부분을 다시 구현할것
	public String playGame(){		
		String res=null;
		if(usr==cpu){
			res = "비겼다.";
		}
		else if(cpu==0){
			if(usr==1)
				res = "이겼다.";
			else
				res = "졌다.";
		}
		else if(cpu==1){
			if(usr==2)
				res = "이겼다.";
			else
				res = "졌다.";
		}
		else if(cpu==2){
			if(usr==0)
				res = "이겼다.";
			else
				res = "졌다.";
		}
		return res;
	}
	
	
	
	@Override
	public String toString() {
		String r = getValue(cpu);
		String v = getValue(usr);
		return String.format("당신 :%s : 컴퓨터=%s / %s", v,
				r, playGame());
	}	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int choice;
		while(true){
		System.out.print("가위/바위/보를 선택(가위:0/바위:1/보:2):");
		choice = sc.nextInt();
		Game d = new Game();		
		
		if(choice<0||choice>2){
			System.out.println("꼼수 쓰지 마세요. 판정패!!");
		}
		else{
			d.setCpu();
			d.setValue(choice);
			System.out.println(d);							}
		}
	}
}
